let Top = document.querySelector('#Top')
let a0 = document.querySelector('#a0')
let a1 = document.querySelector('#a1')
let a2 = document.querySelector('#a2')
let a3 = document.querySelector('#a3')
let aArr = [a0, a1, a2, a3]
let pp = document.querySelectorAll('.pp')
Top.onclick = function () {
    document.documentElement.scrollTop = 0;
}
fetch("http://chst.vip:1234/api/getcoupon")
    .then(body => body.json())
    .then(res => {
        console.log(res);

        for (let i = 0; i < aArr.length; i++) {
            aArr[i].setAttribute('couponId', res.result[i].couponId)
            pp[i].innerHTML = res.result[i].couponTitle
        }
        // http://chst.vip:1234/api/getcouponproduct?couponid=0
        aArr.forEach(item => {
            item.onclick = function () {
                let couponid = this.getAttribute('couponId')
                location.href = `./couponproduct.html?couponid=` + couponid
            }
        });
    })
